﻿using System;
using System.Reflection;
using System.Configuration;

namespace DALFactory
{
    [CLSCompliant(false)]
    public sealed class TTS_DataAccess
    {
        private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];

        private TTS_DataAccess() { }

        //有需要的时候，这个函数可以单独提取出来建一个类，管理与配置文件相关的各种动态对象的创建、维护
        public static object LocateDALObject(string className)
        {
            string fullPath = path + "." + className;
            return Assembly.Load(path).CreateInstance(fullPath);
        }
        
        public static TTSIDAL.IUnit CreateUnit()
        {
            return (TTSIDAL.IUnit)LocateDALObject("Unit");
        }

        public static TTSIDAL.IUnitType CreateUnitType()
        {
            return (TTSIDAL.IUnitType)LocateDALObject("UnitType");
        }

        public static TTSIDAL.IAssemble CreateAssemble()
        {
            return (TTSIDAL.IAssemble)LocateDALObject("Assemble");
        }

        public static TTSIDAL.IAssembleItem CreateAssembleItem()
        {
            return (TTSIDAL.IAssembleItem)LocateDALObject("AssembleItem");
        }

        public static TTSIDAL.IKCCSNUnion CreateKCCSNUnion()
        {
            return (TTSIDAL.IKCCSNUnion)LocateDALObject("KCCSNUnion");
        }
        public static TTSIDAL.IT0002028Detail CreateT0002028Detail()
        {
            return (TTSIDAL.IT0002028Detail)LocateDALObject("T0002028Detail");
        }
        public static TTSIDAL.IT0002028Summary CreateT0002028Summary()
        {
            return (TTSIDAL.IT0002028Summary)LocateDALObject("T0002028Summary");
        }
        public static TTSIDAL.IT0001996Detail CreateT0001996Detail()
        {
            return (TTSIDAL.IT0001996Detail)LocateDALObject("T0001996Detail");
        }
        public static TTSIDAL.IT0001996Summary CreateT0001996Summary()
        {
            return (TTSIDAL.IT0001996Summary)LocateDALObject("T0001996Summary");
        }
        public static TTSIDAL.IT0002038Detail CreateT0002038Detail()
        {
            return (TTSIDAL.IT0002038Detail)LocateDALObject("T0002038Detail");
        }
        public static TTSIDAL.IT0002038Summary CreateT0002038Summary()
        {
            return (TTSIDAL.IT0002038Summary)LocateDALObject("T0002038Summary");
        }
        public static TTSIDAL.IT0002199Detail CreateT0002199Detail()
        {
            return (TTSIDAL.IT0002199Detail)LocateDALObject("T0002199Detail");
        }
        public static TTSIDAL.IT0002199Summary CreateT0002199Summary()
        {
            return (TTSIDAL.IT0002199Summary)LocateDALObject("T0002199Summary");
        }
     
        //public static TTSIDAL.IRRH_Reporting CreateRRHReporting()
        //{
        //    return (TTSIDAL.IRRH_Reporting)LocateDALObject("RRHReporting");
        //}
        //public static TTSIDAL.IDM_T0002358_Reporting CreateDM_T0002358Reporting()
        //{
        //    return (TTSIDAL.IDM_T0002358_Reporting)LocateDALObject("DM_T0002358_Reporting");
        //}
        //public static TTSIDAL.IT0002028_OPR CreateT0002028_OPR()
        //{
        //    return (TTSIDAL.IT0002028_OPR)LocateDALObject("T0002028_OPR");
        //}
        //public static TTSIDAL.IT0002028_CPK CreateT0002028_CPK()
        //{
        //    return (TTSIDAL.IT0002028_CPK)LocateDALObject("T0002028_CPK");
        //}
        public static TTSIDAL.ITestStatus CreateTestStatus()
        {
            return (TTSIDAL.ITestStatus)LocateDALObject("TestStatus");
        }
        public static TTSIDAL.IAxisValue CreateAxisValue()
        {
            return (TTSIDAL.IAxisValue)LocateDALObject("AxisValue");
        }
        public static TTSIDAL.ICPKParameterValue CreateCPKParameterValue()
        {
            return (TTSIDAL.ICPKParameterValue)LocateDALObject("CPKParameterValue");
        }
        public static TTSIDAL.IAirtightnessTek CreateAirtightnessTek()
        {
            return (TTSIDAL.IAirtightnessTek)LocateDALObject("AirtightnessTek");
        }

        public static TTSIDAL.IPackage CreatePackage()
        {
            return (TTSIDAL.IPackage)LocateDALObject("Package");
        }
    }
}
